package common;

import java.util.ArrayList;
import java.util.List;
import common.Tables.Table;

/**
 * interface with function on DB
 * Server implements this interface and 
 * override functions with the behavior 
 * they should act on server side
 * 
 * @author Orit
 *
 */
public interface ServerInterface {
	/**
	 * add client to data base
	 * @param clientName : list of [client name,client id]
	 * @throws Exception 
	 */
	public void addClientToDB(ArrayList<ArrayList<String>> clientName) throws Exception;
	/**
	 * add User To DB include id, first name, password, permission
	 */
	public void addUserToDB(String id, String firstName,
			String password, String permission) throws Exception;
	/**
	 * add task to DB include task name && weight
	 */
	public void addTaskToDB(String taskName, int weight) throws Exception;

	/**
	 * get unscheduled Arrangements with client id and task id  
	 */
	public List<Table> getUnArrangementForClientAndTasks(long clientId, int taskId);

	/**
	 * auto scheduled - 
	 * @param date - first date to scheduled
	 * @param otherDate- another date to scheduled
	 * @param arriveDate - the arrive date of all candidates to scheduled.
	 * return the Table of psychologists with their scheduled.   
	 */
	public CommandAnswer automaticScheduling(String date, String otherDate, String arriveDate) throws Exception;

	/**
	 * get clients - or by their id or by their names 
	 */
	public List<Table> getClients(long clientId, String clientName);

	/**
	 * get candidates - with all options: candidate name,ids,jobs,client name.
	 */	
	public List<Table> getCandidates(String candidateName,String candidateLastName,String candidateId,
			String candidateJob, String clientName);

	/**
	 * get Candidate Arrive with all options: client id, client name, 
	 * 	   candidate id, candidate first&& last name,job id,arriver date,task,notes.
	 */
	public List<Table> getClientsCandidates(long clientId, String clientName,
			String candidateId, String candidateFirstName,String candidateLastName,
			String candidateArriveDate,long jobId,String job,String notes,String taskName);

	/**
	 * get arrangements with all options: id,client,candidate,job,task,psychologists.
	 */
	public List<Table> getArrangements(long id, long clientId, String candidateId,long jobId, int taskId, 
			String arrangeDate, String clientName,String candidateFirstName,
			String candidateLastName,String job,String task,String psycId,String psycFName,String psycLName);

	/**
	 * get unscheduled arrangements option with params i.e by client id, candidate id,job id or task id
	 * (to all table set all parms -1)
	 */
	public List<Table> getUnArrangements(long clientId,String candidateId,long jobId,int taskId);	
	
	/**
	 * get jobs by id or by name
	 */
	public List<Table> getJobs(long jobId, String jobName);
		

	/**
	 * add one job to data base
	 */
	public void addJobToDB(String jobName);

	/**
	 * save Scheduling of this psychologists list, with today && tomorrow arranges,
	 * 														in date && other date
	 */
	public void saveScheduling(List<String> psycList, List<List<String>> todayArranges,
			List<List<String>> tomorrowArranges, List<String> unArranges, String date, String tomorrowDate);
	/**
	 * get psychologists all table with all set initialize in server
	 */
	public List<Table> getPsychWithAllSets();
	
	/**
	 * method gets a list of string list format and deletes all corresponding rows
	 * @param delList - [candidate id,candidate first name,candidate last name] 
	 * @throws Exception if the client was not found. 
	 */
	public void deleteClients(ArrayList<ArrayList<String>> newClients) throws Exception;
	
	/**
	 * delete all candidates from Candidate Arrive Table. 
	 * oldRows.get(0).get(0) - candidate id.
	 * oldRows.get(0).get(1) - candidate first name.
	 * oldRows.get(0).get(2) - job name.
	 * oldRows.get(0).get(3) = client name. (can't be updated yet)
	 * oldRows.get(0).get(4) = client id.
	 * oldRows.get(0).get(5) = arrive Date
	 * @param oldRows , newRows
	 * @throws Exception's message that thrown from Server. 
	 */
	public void deleteCandidates(ArrayList<ArrayList<String>> candidates) throws Exception;

	/**
	 * get All Arrangement Psychologists in this date.
	 */
	public List<List<Table>> getAllArrangementPsyc(String arrangeDate);
	
	/**
	 * add unusual UnArrangements from gui. 
	 */
	public void addUnArrangements(ArrayList<ArrayList<String>> arranges, boolean isByName) throws Exception;
	
	/**
	 * add candidate with job and client to Database IN format 
	 * @param unArr: [client id,client name,candidate id,candidate name,job,candidate arrive date,notes]
	 * @throws Exception - throw if the client do not exist in system.
	 */
	public void addCandidateArrives(ArrayList<ArrayList<String>> clientCandidate) throws Exception;
	/**
	 * method gets a list of string list in the format: 
	 * delList.get(0).get(0) = client name 
	 * delList.get(0).get(1) = candidate id
	 * delList.get(0).get(2) = job name
	 * delList.get(0).get(3) = task name
	 * and deletes all corresponding rows
	 * @param delList
	 * @throws Exception 
	 */
	public void deleteArrangemets(ArrayList<ArrayList<String>> arranges) throws Exception;

	/**
	 * @param oldRows
	 * 	oldRows.get(0).get(0) - client id (can be anything find client by name)
	 * 	oldRows.get(0).get(1) - old client name
	 * @param newRows
	 * 	newRows.get(0).get(0) - client id (can be anything find client by name)
	 *  newRows.get(0).get(0) - new client name 
	 * @throws Exception's message that thrown from Server. 
	 */	
	public void updateClients(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newClients) throws Exception;
	/**
	 * @param oldRows , newRows to update in format
	 * oldRows.get(0).get(0) = client name  
	 * oldRows.get(0).get(0) - candidate id 
	 * oldRows.get(0).get(1) - job name     
	 * oldRows.get(0).get(2) - task name	
	 * @throws Exception's message that thrown from Server. 
	 */	
	public void updateArrangemets(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> arranges)throws Exception;
	
	/**
	 * update candidate name,last name, job: 
	 * oldRows.get(0).get(0) - candidate id - key not changed yet.
	 * oldRows.get(0).get(1) - candidate first name
	 * oldRows.get(0).get(2) - job name.
	 * oldRows.get(0).get(3) = client name. (can't be updated yet)
	 * oldRows.get(0).get(4) = client id.
	 * oldRows.get(0).get(5) = arrive Date
	 * @param oldRows , newRows
	 * @throws Exception's message that thrown from Server. 
	 */
	public void updateCandidates(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> clientCandidate)throws Exception;
	/**
	 * get arrangements by date from and date to.  
	 */
	public List<Table> getArrangementsByDate(String dateFrom, String dateTo);
	/**
	 * get all unscheduled arrangements option with params i.e by client id, candidate id,job id or task id
	 * (to all table set all parms -1)
	 */
	public List<Table> getUnArrangements(long clientId, String candidateId,long jobId, int taskId, 
			String clientName,String candidateFirstName,String candidateLastName,String job,String task,String arriveDate);

	/**
	 * get giving tasks with all options!!
	 */
	List<Table> getGivingTasks(String taskName, int taskId, String clientName,
			long clientId, String jobName);
	/**
	 * add giving tasks to DB 
	 * @param givingTasks- [CLIENT ID,CLIENT NAME,JOB NAME, ALL TASKS]  
	 */
	public void addGivingTasks(ArrayList<ArrayList<String>> givingTasks) throws Exception;
	/**
	 * delete Giving task by client and job.
	 * @param givingTasks- [CLIENT ID,CLIENT NAME,JOB NAME, ALL TASKS]  
	 */
	public void deleteGivingTasks(ArrayList<ArrayList<String>> givingTasks) throws Exception;
	/**
	 * update giving tasks
	 * @param oldRows- [CLIENT ID,CLIENT NAME,JOB NAME, ALL TASKS]  
	 * @param newRows- [CLIENT ID,CLIENT NAME,JOB NAME, ALL TASKS]  
	 */
	public void updateGivingTasks(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> givingTasks) throws Exception;
	/**
	 * update unArrangement (from dynamic grouping Tab)
	 * @param currentArrangements
	 * @param candidateArrives
	 */
	public void updateUnArrangemets(List<Table> currentArrangements,
			ArrayList<ArrayList<String>> arranges);
	/**
	 * add all the Jobs To Client set. 
	 * @param newRows - list of [client id,client name,job name] to add to DB. 
	 */	
	public void addJobsToClient(ArrayList<ArrayList<String>> oldRows) throws Exception;
	/**
	 * delete all the Jobs from Client set. 
	 * @param oldRows - list of [client id,client name,job name] to delete from DB. 
	 */
	public void deleteJobsClient(ArrayList<ArrayList<String>> oldRows) throws Exception;
	/**
	 * update all the Jobs To Client set. 
	 * @param oldRows - list of [client id,client name,job name] to delete from DB.
	 * @param newRows - list of [client id,client name,job name] to add to DB. 
	 */	
	public void updateJobsClients(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
	/**
	 * get get Arrangements With ArrayList that have or connection between them
	 * 			includes: ids , candidate ids, candidate name,psychologists name,clients ids,
	 * 			client name, scheduled date from and scheduled date to. 
	 */
	public List<Table> getArrangementsWithArrayList(ArrayList<String> ids,
			ArrayList<String> candIds, ArrayList<String> candNames,
			ArrayList<String> psychsNames, ArrayList<String> clientsIds, ArrayList<String> clientsNames, String arrangeDate, String dateTo);	
	/**
	 * get availability by his id, date,notes
	 */
	public List<Table> getAvailability(long avlID, String date, String notes);
	/**
	 * delete Psychologists which availability include his id, date from,date to,every X days,notes
	 */
	public void deletePsychAvailability(ArrayList<ArrayList<String>>oldRows);
	/**
	 * ADD Tasks to PSYCHOLOGISTS as scheduled 
	 */
	public void addPsychCompletedMissions(String psychID, int clientID,
			String candidateID, int taskID) throws Exception;
	/**
	 * add tasks to psychologists permissions
	 */
	public void addTaskPerPsych(ArrayList<ArrayList<String>> TPPs) throws Exception;
	
	/**
	 * add list of psychologists include id and full names.
	 */
	public void addPsych(ArrayList<ArrayList<String>> psychs) throws Exception;

	/**
	 * get list of psychologists include id and full names.
	 */
	public List<Table> getPsychs(String firstName,String lastName,String id,boolean withSets);
	/**
	 * add tasks include task name and weight
	 */
	public void addTasks(ArrayList<ArrayList<String>> tasks) throws Exception;
	/**
	 * get tasks include list of task name and weight
	 */	
	public List<Table> getTasks(String taskName,int weight,int taskID,String psychID);
	/**
	 * verify user sign in with user name and password
	 */	
	public void userSignIn(String username, String password) throws Exception;
	/**
	 * add users include user name and password
	 */
	public void addUsers(ArrayList<ArrayList<String>> users) throws Exception;
	/**
	 * get users include user name and password
	 */
	public List<Table> getUsers(String id,String firstName,String lastName,String password,String permission);
	/**
	 * add Psychologists which Unavailability add his id, date from,date to,every X days,notes
	 */
	public void addPsychUnavailability(String psychID,String dateFrom,String dateTo,
			String day, String everyX, String time,String notes) throws Exception;
	/**
	 * update Psychologists which availability update his id, date from,date to,every X days,notes
	 */
	public void updatePsychAvailability(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
	/**
	 * get Psychologists which availability uget by his id, date from,date to,every X days,notes
	 */
	public List<Table> getPsychAvailability(String psychID, String date,
			String notes, String dateFrom, String dateTo,
			String psychLastName, String psychFirstName,boolean getAvailable,
			ArrayList<String> psychsNames,boolean ANDrelation);
	/**
	 * get tasks per psychologists by psychologists id, task id , notes
	 */
	public List<Table> getTaskPerPsych(String psychID, int taskID, String notes);
	/**
	 * returns psychologists by psych id, weightPerDay, currentWeight, etc.. 
	 */
	public List<Table> getPsychTasksWeight(String psychID, float weightPerDay,
			float currentWeight, float tomorrowWeight,String date);
	/**
	 * updates psychologists according to given oldRows and newRows
	 */
	public void updatePsychTasksWeights(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
    /**
	* updates existing psychs or deletes psychs
	*/
	public void updatePsych(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
	/**
	 * updates existing or deletes tasks
	 */
	public void updateTasks(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows)  throws Exception;
	/**
	* updates existing or deletes users
	*/
	public void updateUsers(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
	/**
	 * updates existing or deletes TaskPerPsych
	 */
	public void updateTaskPerPsych(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows);
	/**
	 * get tasks with all options!! include by task name,id, weight,psychologists name,id. 
	 */		
	public List<Table> getTasks(String taskName,float weight,int taskID,String psychID,String firstName,String lastName,String notes);
	public void resetPassword(ArrayList<ArrayList<String>> users);
	/**
	 * update Diagnostics Availability.
	 * @param oldRows - list of Diagnostics Availability to delete from DB.
	 * @param newRows - list of Diagnostics Availability  to add to DB. 
	 */
	public void updateDiagAvailability(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
	/**
	 * delete Diagnostics Availability.
	 * @param oldRows - list of Diagnostics Availability to delete from DB.
	 */
	public void deleteDiagAvailability(ArrayList<ArrayList<String>> oldRows);
	/**
	 * get Diagnostics Availability by all options include psychologists,date,notes
	 */
	public List<Table> getDiagAvailability(String psychID, String date,
			String notes, String dateFrom, String dateTo, String psychLastName,
			String psychFirstName, boolean getAvailable,
			ArrayList<String> psychsNames, boolean aNDrelation);
	/**
	 * add Diagnostics .
	 * @param psychs - list of Diagnostics  to add to DB. 
	 */
	public void addDiag(ArrayList<ArrayList<String>> psychs) throws Exception;
	
	/**
	 * get Diagnostics by all option include: by first name,last name,id
	 * @param withSets - true if sets needed in client side false otherwise. 
	 */
	public List<Table> getDiags(String firstName, String lastName, String id,
			boolean withSets);
	/**
	 * update Diagnostics .
	 * @param oldRows - list of Diagnostics  to delete from DB. 
	 * @param newRows - list of Diagnostics  to add to DB. 
	 */	
	public void updateDiag(ArrayList<ArrayList<String>> oldRows,
			ArrayList<ArrayList<String>> newRows) throws Exception;
	/**
	 * change Password from oldPass to newPass of the user with this id
	 */
	public void changePassword(String id, String oldPass, String newPass) throws Exception;
	

}
